﻿using System;
using System.Globalization;
using System.Runtime.Serialization;

namespace Xtreme.Json
{
  [Serializable]
  public class JsonParserException : Exception
  {
    public JsonParserException()
    {
    }

    public JsonParserException(String message)
      : base(message)
    {
    }

    public JsonParserException(String message, Exception innerException)
      : base(message, innerException)
    {
    }

    protected JsonParserException(SerializationInfo info, StreamingContext context)
      : base(info, context)
    {
    }

    public override void GetObjectData(SerializationInfo info, StreamingContext context)
    {
      if (info == null)
      {
        throw new ArgumentNullException("info");
      }

      base.GetObjectData(info, context);
      info.AddValue("Line", Line);
      info.AddValue("Column", Column);
    }

    public int Line { get; set; }

    public int Column { get; set; }

    public override string Message
    {
      get { return String.Format(CultureInfo.InvariantCulture, "{0} (Line: {1}, Column: {2})", base.Message, Line, Column); }
    }
  }
}